<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
    <%@ page contentType="text/html;charset=UTF-8" %>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <title>登录</title>
    <%@include file="includes/common.jsp" %>
</head>
<body style="padding: 0;">
<div class="container">
    <section class="loginBox row-fluid">
        <h2>用户登录</h2>

        <form>
            <p>账号<input type="text" id="username" name="username" placeholder="用户名" value="admin"
                      style="height: 30px;line-height: 30px;margin-bottom: 5px;margin-right: 1px"/></p>

            <p>密码<input type="password" id="password" name="password" placeholder="密码" value="admin"
                      style="height: 30px;line-height: 30px;margin-bottom: 5px;"/></p>
            <div>
                验证码：
                <input type="text" value="" name="imageCode" id="imageCode" width="30" height="22"
                       style="padding-top: 1px;">
                &nbsp;<img name="randImage" id="randImage" width="80" height="22" style="margin-bottom: -3px" src="tourist/showImage"/>
                &nbsp; <a onclick="reloadValidate()">换一张</a>
            </div>
            <br/>
            <section class="row-fluid">
                <section class="span1" style="margin-left: 35%;">
                    <input type="button" value=" 登录 " class="btn btn-primary" style="line-height: 30px;" onclick="login()"/>
                </section>
            </section>
        </form>
    </section>
    <!-- /loginBox -->
</div>
<!-- /container -->
</body>
</html>
<script type="text/javascript">
    //session过期跳转登录页面
//    if (top != window) {
//        top.location.href = "logout"
//    }
    var rules = {
        objInfo: {
            imageCode: {
                checkEmpty: ["imageCode", "验证码"],
                ajax: [basePath + "admin/user/checkRepeatImageCode", {}, {imageCode: "$('#imageCode').val().trim()"},
                    backCode, "text", "POST"]
            }
        }
    };
    function login() {
       // if(!JC.validate(rules)) return;
            formSub()
    }

    function backCode(data, returnObj) {
        returnObj.obj = $('#imageCode');
        returnObj.errMsg = "";
        if (data == "true") {
            returnObj.bool = true;
        }
        if (data == "false") {
            returnObj.bool = false;
        }
        return returnObj;
    }
    $(function () {
        //输入密码回车默认登陆
        $("#password").unbind(".entertotab").bind("keydown.entertotab", function (e) {
            if (e.which == 13) {
                login()
            }
        });
        JC.inputInit();
    })
    function reloadValidate(){
        $("#randImage").attr("src",basePath+"tourist/showImage?_="+Math.random());
    }
</script>